package cn.gok;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.SimpleTimeZone;
import java.util.logging.SimpleFormatter;

/**
 * @ClassName Data类
 * @Description TODO
 * @Author HP
 * @Date 11:27 2022/7/7
 * @Version 1.0
 **/
public class Data类 {
    public static void main(String[] args) throws ParseException {
        Data类的常用用法();
    }

    private static void Data类的常用用法() throws ParseException {
        Date date = new Date();
        System.out.println(date);
        SimpleDateFormat simpleTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(simpleTimeFormat.format(date));
        String time = "2000-01-01 12:00:00";
        Date date1 = simpleTimeFormat.parse(time);
        System.out.println(date1);

        System.out.println("距离1970-1-7 0时的毫秒数" + date.getTime());
        long now = date.getTime();
        long then = date.getTime();
        long days = (now - then) / 1000 / (3600 * 24);
        System.out.println("距离的天数" + days);

    }
}
